import { defineStore } from 'pinia';

export const useUserStore = defineStore({
  id: 'user', 
  state: () => ({
    id: 0,
    username: '',
    nickname: '',
    realName: '',
    college: '',
    grade: '',
    avatarUrl: '',
    contactInfo: '',
    createTime: '',
    token: '',
    updateTime: '',
    userClass: '',
    sex: '',
  }),
  actions: {
    setUserData(userData: any) {
      this.id = userData.id;
      this.username = userData.username;
      this.nickname = userData.nickname;
      this.realName = userData.realName;
      this.college = userData.college;
      this.grade = userData.grade;
      this.avatarUrl = userData.avatarUrl;
      this.contactInfo = userData.contactInfo;
      this.createTime = userData.createTime;
      this.token = userData.token;
      this.updateTime = userData.updateTime;
      this.userClass = userData.userClass;
      this.sex = userData.sex;
    },
    clearUserData() {
      this.$reset();
    }
  }
});
